package com.ctbu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ctbu.entity.LoanProduct;
import com.ctbu.entity.LoanProductType;
import com.ctbu.mapper.LoanProductTypeMapper;
import com.ctbu.service.LoanProductTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctbu.tools.ResponseResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 贷款类型表 服务实现类
 * </p>
 *
 * @author lli
 * @since 2024年06月19日
 */
@Service
public class LoanProductTypeServiceImpl extends ServiceImpl<LoanProductTypeMapper, LoanProductType> implements LoanProductTypeService {
    @Autowired
    private LoanProductTypeMapper loanProductTypeMapper;
    @Override
    public ResponseResult<Object> selectList(int pageNum, int pageSize, String loanTypeName) {
        //开启分页
        PageHelper.startPage(pageNum,pageSize);
        //条件查询
        LambdaQueryWrapper<LoanProductType> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        if(!loanTypeName.equals("")){
            lambdaQueryWrapper.like(LoanProductType::getLoanTypeName,loanTypeName);
        }

        List<LoanProductType> list = loanProductTypeMapper.selectList(lambdaQueryWrapper);
        //将查询结果封装到对应分页中
        PageInfo<LoanProductType> pageInfo = new PageInfo<>(list);
        return ResponseResult.success(pageInfo,"查询成功");
    }
}
